Skip to content

Conversation

@chinacat567
Copy link
Contributor

@chinacat567 chinacat567 commented May 12, 2025

Context

  • Read discussion here

Description

  • This PR is moving away from setuptools to uv to manage dependencies
  • A publish workflow can then be used to build and publish dicomweb-client to PyPI (PR to follow soon)

@chinacat567 chinacat567 marked this pull request as draft May 12, 2025 16:59
@chinacat567 chinacat567 marked this pull request as ready for review May 13, 2025 14:20
@medihack
Copy link
Contributor

medihack commented May 13, 2025

@chinacat567 In this case, it would make sense to call the workflow only publish.yml (and not publish-client.yml).

@CPBridge To automatically publish to PyPI when publishing on GitHub, you must allow this on the PyPI homepage by associating the GitHub repo and workflow with the package (it's quite simple).

It would look like this in your case:

PyPI Project Name (required)
dicomweb-client

Owner (required)
ImagingDataCommons

Repository name (required)
dicomweb-client

Workflow name (required)
publish.yml

Environment name (optional) 
(I left this empty)

@medihack
Copy link
Contributor

@chinacat567 I also think that the configurations in setup.cfg can be moved (most probably need to be adapted) into pyproject.toml. I also don't see a need for the setup.py then anymore.

@chinacat567
Copy link
Contributor Author

@chinacat567 I also think that the configurations in setup.cfg can be moved (most probably need to be adapted) into pyproject.toml. I also don't see a need for the setup.py then anymore.

Deleted setup.py and setup.cfg, moving flake8 settings to a .flake8 file.

@medihack
Copy link
Contributor

LGTM now. Looking forward to an upcoming release 🙂.

@CPBridge
Copy link
Collaborator

Thanks! Bit underwater for the next couple of days but I'll take a look later in the week

@CPBridge CPBridge self-assigned this May 14, 2025
@CPBridge CPBridge added the enhancement New feature or request label May 14, 2025
Copy link
Collaborator

@CPBridge CPBridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this nice upgrade @chinacat567 @medihack. I have a few specific comments on the code, and also a question.

I've personally not used automatic versioning before. Can you confirm what is used as the source of the version? Is it the release title or the git tag? I ask because we prepend av in the git tags, but not in the release titles or the version strings and I want to make sure we don't mess this up...

Secondly, there is currently a version number stored within the source code itself in the top level __init__.py such that someone can access dicomweb_client.__version__ within python. From what I can tell, the automatic versioning introduced by this PR would not affect that version string, which would seem to be a big problem. I see the poetry dynamic versioning tool has the capability to do this, but the uv version is very poorly documented as far as I can tell. From what you know, is it possible to have this version string updated automatically too?

uv.lock Outdated
@@ -0,0 +1,1226 @@
version = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, whether to commit a lockfile for a a library project such as this is a matter of debate. It is not required for anyone installing the library (which simply uses the dependency ranges listed in pyproject.toml) and is basically just for developers to have synced environments. But I imagine this will create a lot of noise in commits as these environments are updated.

I generally come down on the side of not committing lock files, but I could be persuaded if there are specific benefits we get from it (personally I am much less familiar with uv than poetry, which I have mostly been using for the last few years).

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right that the usage of lock files is somehow debatable, but I guess, with the increasing spread of uv (and poetry), those are becoming more the default than the exception. I like them for the reproducibility and consistency of my development and testing environment. I also use renovate to automatically update all my dependencies (including the lock files).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted the uv.lock file and put *.lock into .gitignore. So it's gone.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, we can maybe revisit if there's a reason in the future. I should clarify that I'm talking purely about library repos, for other types of project (applications) I think it makes a lot of sense.

That said it seems that you added the lock file to the gitignore but didn't actually git rm it, it's still there! @medihack

@medihack
Copy link
Contributor

medihack commented May 18, 2025

I've personally not used automatic versioning before. Can you confirm what is used as the source of the version? Is it the release title or the git tag? I ask because we prepend av in the git tags, but not in the release titles or the version strings and I want to make sure we don't mess this up...

Ah, ok. I wasn't aware that your tags use a "v" prefix. Dynamic versioning indeed uses the tag and not the release title.
@chinacat567 No need for pattern = "default-unprefixed"

Secondly, there is currently a version number stored within the source code itself in the top level __init__.py such that someone can access dicomweb_client.__version__ within python. From what I can tell, the automatic versioning introduced by this PR would not affect that version string, which would seem to be a big problem. I see the poetry dynamic versioning tool has the capability to do this, but the uv version is very poorly documented as far as I can tell. From what you know, is it possible to have this version string updated automatically too?

You are right. That is a shortcoming I also wasn't aware of. And unfortunately, I don't know an easy solution for it 😞. The uv team plans to integrate the dynamic versioning in uv itself. Hopefully, they will support that use case as well. But it is not there yet.

That said, maybe uv isn't a good fit here (or at least the dynamic versioning and publish workflow). It was just a suggestion to integrate a more "modern" build system (but modern is, of course, not always better, or at least not always a better fit). So if you are happy with the current build system (and it also seems to work well), I am also ok with just closing this PR (and having a release with the current build system 😉).

@CPBridge
Copy link
Collaborator

You are right. That is a shortcoming I also wasn't aware of. And unfortunately, I don't know an easy solution for it 😞. The uv team plans to integrate the dynamic versioning in uv itself. Hopefully, they will support that use case as well. But it is not there yet.

I think perhaps this (the hook) could be a solution?

@medihack
Copy link
Contributor

I think perhaps this (the hook) could be a solution?

Ah interesting ... I didn't know about that. I used importlib.metadata (I guess performance isn't that critical).

@medihack
Copy link
Contributor

medihack commented May 19, 2025

I can't check if the correct git tag is picked up as a version. So, if you really want to merge it, try it out manually first before publishing a new release by running uv build.

Copy link
Collaborator

@CPBridge CPBridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

So, if you really want to merge it, try it out manually first before publishing a new release by running uv build.

I just tried this and it seems to work correctly. I.e. building when at commit tagged with a v (e.g. v0.60.0) produces a version without a v (0.60.0) and when imported, the module's __version__ attribute is the tag without the v (0.60.0)

Just one little thing about the lock file...

uv.lock Outdated
@@ -0,0 +1,1226 @@
version = 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks, we can maybe revisit if there's a reason in the future. I should clarify that I'm talking purely about library repos, for other types of project (applications) I think it makes a lot of sense.

That said it seems that you added the lock file to the gitignore but didn't actually git rm it, it's still there! @medihack

@CPBridge
Copy link
Collaborator

Also, any concerns from @pieper before finalising?

@sonarqubecloud
Copy link

@medihack
Copy link
Contributor

uv.lock is removed (I just deleted it and added it to .gitignore in the same commit, which of course can't work 🙈).

Another good addition would be to switch from flake8 to ruff. But let's tackle that in a separate PR sometime later.

@CPBridge CPBridge merged commit ded157f into ImagingDataCommons:master May 24, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants